home *** CD-ROM | disk | FTP | other *** search
- #include "custctl.h"
- #include "nradio.h"
- #include <edit.h>
- #include <bstatic.h>
- #include <windowsx.h>
-
- char CRadioClassName[] = "CRADIO"; // class for new custom control
-
- #include "ctlids.h"
-
- /*******************************************************************
- TCRadio - A New radio button class.
- *******************************************************************/
- TCRadio::TCRadio(PTWindowsObject AParent, int AnId,
- LPSTR ATitle, int X, int Y, int W, int H,
- PTModule AModule)
- : TStateButton(AParent, AnId, ATitle, X, Y, W, H,
- AModule)
- {
- On = LoadBitmap(DLLModule->hInstance, "CRADIO_ON_BMP");
- Off = LoadBitmap(DLLModule->hInstance, "CRADIO_OFF_BMP");
- Mask = LoadBitmap(DLLModule->hInstance, "CRADIO_MASK_BMP");
- }
-
- TCRadio::TCRadio(PTWindowsObject AParent, int ResourceId,
- PTModule AModule)
- : TStateButton(AParent, ResourceId, AModule)
- {
- On = LoadBitmap(DLLModule->hInstance, "CRADIO_ON_BMP");
- Off = LoadBitmap(DLLModule->hInstance, "CRADIO_OFF_BMP");
- Mask = LoadBitmap(DLLModule->hInstance, "CRADIO_MASK_BMP");
- }
-
- TCRadio::~TCRadio()
- {
- DeleteObject(On);
- DeleteObject(Off);
- DeleteObject(Mask);
- }
-
- LPSTR TCRadio::GetClassName()
- {
- return CRadioClassName;
- }
-
- void TCRadio::DrawOn(HDC DrawDC)
- {
- HDC CopyDC = CreateCompatibleDC(DrawDC);
- HBITMAP Old = SelectBitmap(CopyDC, Mask);
-
- BitBlt(DrawDC, 0, 0, 20, 20, CopyDC, 0, 0, SRCAND);
-
- SelectBitmap(CopyDC, On);
-
- BitBlt(DrawDC, 0, 0, 20, 20, CopyDC, 0, 0, SRCINVERT);
-
- SetBkMode(DrawDC, TRANSPARENT);
- SendMessage(Parent->HWindow, WM_CTLCOLOR,
- (WPARAM)DrawDC, MAKELPARAM(HWindow,
- CTLCOLOR_STATIC));
-
- char Text[80];
- GetWindowText(HWindow, Text, 80);
- TextOut(DrawDC, 22, 2, Text, lstrlen(Text));
-
- SelectBitmap(CopyDC, Old);
- DeleteDC(CopyDC);
- }
-
- void TCRadio::DrawOff(HDC DrawDC)
- {
- HDC CopyDC = CreateCompatibleDC(DrawDC);
- HBITMAP Old = SelectBitmap(CopyDC, Mask);
-
- BitBlt(DrawDC, 0, 0, 20, 20, CopyDC, 0, 0, SRCAND);
-
- SelectBitmap(CopyDC, Off);
-
- BitBlt(DrawDC, 0, 0, 20, 20, CopyDC, 0, 0, SRCINVERT);
-
- SetBkMode(DrawDC, TRANSPARENT);
- SendMessage(Parent->HWindow, WM_CTLCOLOR,
- (WPARAM)DrawDC, MAKELPARAM(HWindow,
- CTLCOLOR_STATIC));
-
- char Text[80];
- GetWindowText(HWindow, Text, 80);
- TextOut(DrawDC, 22, 2, Text, lstrlen(Text));
-
- SelectBitmap(CopyDC, Old);
- DeleteDC(CopyDC);
- }
-
- void TCRadio::GetWindowClass(WNDCLASS _FAR& WndClass)
- {
- TStateButton::GetWindowClass(WndClass);
-
- WndClass.hbrBackground = NULL;
- }